<%@page import="beans.Account"%>
<%@page import="dao.MngClass"%>
<%@page import="java.util.List"%>
<%@page import="dao.CheckAccount"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Update Class Page</title>
    </head>
    <body>      
        <%
            if (request.getAttribute("msg") != null) {
        %>
        <font color="green" > <%= request.getAttribute("msg")%> </font>
        <%
            }
        if (request.getAttribute("error") != null) {
        %>
        <font color="red" > <%= request.getAttribute("error")%> </font>
        <%
            }
        %>
        <form action="updateClass" method="get">
            <table>
                <strong>Class ID : <%= request.getAttribute("class_id")%> </strong><br>            
                <input type="hidden" name="class_id" value="<%= request.getAttribute("class_id")%>"><br>
                <tr>
                    <td> Class name</td>
                    <td>                    
                        <input type="text" name="class_name" value="<%= request.getAttribute("class_name")%>"><font color="red">*</font>    
                    </td>
                </tr>
                <tr>
                    <td>Staff</td>
                    <td> 
                        <%
                            CheckAccount ck = new CheckAccount();
                            List<Account> list_staff = ck.listAccByRoll("staff");
                        %>
                        <select name="acc_id">
                            <option value="<%= request.getAttribute("acc_id")%>"><%= ck.getFullName(request.getAttribute("acc_id").toString())%></option>
                            <%
                                for (Account acc : list_staff) {
                                    if (!acc.getAcc_id().equals(request.getAttribute("acc_id").toString())) {
                            %> 
                            <option value="<%= acc.getAcc_id()%>"><%= acc.getFull_name()%></option>
                            <% }
                                }%>
                        </select><font color="red">*</font>
                    </td> 
                </tr>
                <tr>
                    <td>Start Date</td>
                    <td> <input type="date" name="start_date" value="<%= request.getAttribute("start_date")%>"> </td>
                </tr>
                <tr>
                    <td>Finish Date</td> 
                    <td><input type="date" name="finish_date" value="<%= request.getAttribute("finish_date")%>"></td>
                </tr>              
                <tr>
                    <td>Description</td>
                    <td> <input type="text" name="description" value="<%= request.getAttribute("description")%>"></td>
                </tr>
                <tr>
                    <td></td>
                    <td> <input type="submit" value="Update"></td>
                </tr>
            </table>
        </form>
    </body>
</html>
